package digital_cash_system.bank;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;

import digital_cash_system.Logger;
import digital_cash_system.XJFrame;

public class BankGUI extends XJFrame implements ActionListener
{
	private static final long serialVersionUID = 1L;

	private final static String startListeningButtonTitle = "Start listening";

	private JButton startListeningButton;

	public BankGUI()
	{
		super("Bank");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

		setSize(850, 600);
		setLocation(100, 100);
		setResizable(false);
		setLayout(null);

		// --- setup menu
		int buttonYPosition = ButtonsMenuYPosition;

		startListeningButton = new JButton(startListeningButtonTitle);
		startListeningButton.setBounds(ButtonsMenuXPosition, buttonYPosition, 200, 50);
		add(startListeningButton);
		startListeningButton.addActionListener(this);
		// ---

		loggerView.setBounds(300, 10, 500, 500);
		loggerView.setEditable(false);
		add(loggerView);

		setVisible(true);
	}

	public static void main(String[] args)
	{
		new BankGUI();
	}

	@Override
	public void actionPerformed(ActionEvent e)
	{
		Object source = e.getSource();
		if (source == startListeningButton)
		{
			// --- logger output
			Logger.getInstance().write("Start listening for connections...");
			// ---
			new Bank();
		}
	}
}
